Streaming events for copyFolder#2189
Merged
Merged
Conversation
… repositories Implements the 'copy files remotely' API in @huggingface/hub, porting the Python huggingface_hub.HfApi.copy_files functionality to TypeScript/JS. Supports: - Bucket-to-bucket copy (server-side, no data transfer) - Repo (model/dataset/space) to bucket copy - xet-backed files: server-side copy by hash - non-xet files: download + re-upload via commit - Single file and recursive folder copy - hf:// handle parsing with revision support Reference: huggingface/huggingface_hub#3874 Co-authored-by: Lucain <Wauplin@users.noreply.github.com>
# Conflicts: # packages/hub/src/lib/copy-files.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For when many small files not tracked by git
Note
Medium Risk
Introduces new async-generator APIs and refactors
copyFile/copyFiles/copyFolderinternals to stream download progress, which changes control flow around downloads/commits and could affect edge cases (errors, cancellation, concurrency). Core copy semantics remain the same and server-side xet copies are untouched.Overview
Adds streaming progress support to copy operations by introducing
CopyProgressEventplus async-iterator variantscopyFileIter,copyFilesIter, andcopyFolderIter.Refactors the download path to a generator-based pipeline (
resolveCopyOperationsIter,downloadAndFillBlobsIter) that yields afileDownloadedevent as each non-xet (git-stored) source file finishes downloading, while keeping xet-backed server-side copies silent. The existingcopyFile/copyFiles/copyFolderAPIs now run these iterators to completion to preserve prior behavior.Reviewed by Cursor Bugbot for commit f35a727. Bugbot is set up for automated code reviews on this repo. Configure here.